package com.smscenter.server.core.vcomcn;


import com.smscenter.server.core.IExecutor;
import com.zeus.base.smscenter.common.constant.SmsConstants;
import com.zeus.base.smscenter.common.constant.VComcnConstants;
import com.zeus.base.smscenter.common.security.MD5;
import com.zeus.base.smscenter.common.util.WebUtils;

import java.io.IOException;

import java.util.Map;

/**
 * Created by Administrator on 2016-02-17.
 */
public class VComSmsExecutor implements IExecutor {
	
	public static void main(String[] args) throws IOException {
		System.out.println(MD5.generate("82557339",false));
//		Map map = new HashMap();//fytest1 82557339
//		map.put("loginName", "fytest1");
//		map.put("loginPassword", MD5.generate("82557339",false).toUpperCase());
//		map.put("phone", "15504607909");
//		map.put("content", "发货通知,已发货");
//		map.put("bizNo", "HJ8JFJ93");
//		VComSmsExecutor v = new VComSmsExecutor();
//		String s = v.excute(map);
//		System.out.println(s);
	}

    public String excute(Map<String, Object> params) throws IOException {
        String loginName = (String) params.get("loginName");//用户名
        String loginPassword = (String) params.get("loginPassword");//密码
        String phone = (String) params.get("phone");//电话号
        String content = (String) params.get("content");//内容
        String bizNo = (String) params.get("bizNo");//唯一ID
        StringBuffer sb = new StringBuffer();
        sb.append("<Group Login_Name='").append(loginName).append("' Login_Pwd='").append(loginPassword).append("' OpKind='0' InterFaceID='15'>");
        sb.append("<E_Time></E_Time>");
        sb.append("<Item>");
        sb.append("<Task>");
        sb.append("<Recive_Phone_Number>").append(phone).append("</Recive_Phone_Number>"); //接收号码
        sb.append("<Content><![CDATA[").append(content).append("]]>");//信息内容
        sb.append("</Content>");
        sb.append("<Search_ID>").append(MD5.generate(bizNo,false)).append("</Search_ID>"); //唯一ID
        sb.append("</Task>");
        sb.append("</Item>");
        sb.append("</Group>");
        String rsp = WebUtils.doPost(VComcnConstants.SMS_URL, sb.toString(), SmsConstants.CHARSET_GBK, 10000, 10000);
        return rsp;
    }
}
